home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / toglprnt / togglprt.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  2.8 KB  |  80 lines

  1. VERSION 2.00
  2. Begin Form togglprt 
  3.    Caption         =   "Set Default Printer"
  4.    ClientHeight    =   1020
  5.    ClientLeft      =   1275
  6.    ClientTop       =   3270
  7.    ClientWidth     =   3720
  8.    Height          =   1425
  9.    Icon            =   TOGGLPRT.FRX:0000
  10.    Left            =   1215
  11.    LinkMode        =   1  'Source
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   1020
  15.    ScaleWidth      =   3720
  16.    Top             =   2925
  17.    Width           =   3840
  18.    Begin CommandButton ToggleBtn 
  19.       Caption         =   "ToggleBtn"
  20.       Height          =   375
  21.       Left            =   120
  22.       TabIndex        =   0
  23.       Top             =   480
  24.       Width           =   3495
  25.    End
  26.    Begin Label DefaultPrinter 
  27.       Alignment       =   2  'Center
  28.       Caption         =   "Default Printer"
  29.       Height          =   255
  30.       Left            =   120
  31.       TabIndex        =   1
  32.       Top             =   120
  33.       Width           =   3495
  34.    End
  35. Const Cr = "Copyright JSS, Inc. 1992 - Steve Schiavo, Center Point, TX"
  36. Sub Form_Load ()
  37.   HP2Default = Space$(128)
  38.   FAXdefault = Space$(128)
  39.   MaxSiz = 128
  40.  'Load constants HP2Default and FAXdefault w/precise description of two printers in .INI file
  41.  '(Note: You must HAVE lines in your Win.Ini file for "HP2Key= . . ." and "FAXKey= . . .")
  42.   NumChars% = GetProfileString("windows", "HP2Key", "", HP2Default, MaxSiz)
  43.   NumChars% = GetProfileString("windows", "FAXKey", "", FAXdefault, MaxSiz)
  44.  'Invoke the core process for the first time
  45.   WasMinimized = True
  46. '  Form_Resize
  47. End Sub
  48. Sub Form_Resize ()
  49.   On Error GoTo FileError
  50.   Current$ = Space$(128)
  51.   MaxSiz = 128
  52.   If NowMinimized() Then WasMinimized = True  ' Record for future how it "last" was
  53.   If WasMinimized And NowNormal() Then        ' This means he "restored" it
  54.      WasMinimized = False                     ' Record so we don't invoke when we minimize
  55.      NumChars% = GetProfileString("windows", "device", "", Current$, MaxSiz)
  56.      DefaultPrinter.Caption = "Current printer is " + Strip(Current$)
  57.      If Current$ = HP2Default Then Target = FAXdefault Else Target = HP2Default
  58.      ToggleBtn.Caption = ToggleTo + Strip(Target)
  59.   End If
  60.   Exit Sub
  61. FileError:
  62.   MsgBox "Can't Open File", 16, Error$(Err)
  63.   Resume Next
  64. End Sub
  65. Function NowMinimized () As Integer
  66.   If WindowState = 1 Then NowMinimized = True Else NowMinimized = False
  67. End Function
  68. Function NowNormal () As Integer
  69.   If WindowState = 0 Then NowNormal = True Else NowNormal = False
  70. End Function
  71. Function Strip (CommaString As String) As String
  72.     x% = InStr(CommaString, ",")
  73.     Strip = Left$(CommaString, x% - 1)
  74. End Function
  75. Sub ToggleBtn_Click ()
  76.   NumChars% = WriteProfileString("windows", "device", Target)
  77.   WindowState = 1 ' Minimize it
  78.   x = DoEvents()
  79. End Sub
  80.